#include "ModelPanel.h"


ModelPanel::ModelPanel(wxFrame* parent): wxPanel(parent),m_parent(parent), m_drawModel(NULL)
{

}

bool ModelPanel::setup()
{
    SetBackgroundColour( wxColor(0,0,0) );

    return true;
}

bool ModelPanel::teardown()
{

    return false;
}

void ModelPanel::setModelDraw(ModelDraw* drawModel)
{
    m_drawModel = drawModel;
}

void ModelPanel::OnPaint(wxPaintEvent &event)
{
    wxPaintDC pdc(this);
    if( m_drawModel ){
        m_drawModel->drawModel();
        m_drawModel->blit( pdc );
    }
}

void ModelPanel::OnMouseMove(wxMouseEvent &event)
{
    wxPoint pos = event.GetPosition();
    //long x = dc.DeviceToLogicalX( pos.x );
    //long y = dc.DeviceToLogicalY( pos.y );
    long x = ( pos.x );
    long y = ( pos.y );

    wxString str;
    str.Printf( wxT("X,Y: %d,%d"), (int)x, (int)y );
    m_parent->SetStatusText( str );
}

BEGIN_EVENT_TABLE(ModelPanel, wxPanel)
    EVT_PAINT  (ModelPanel::OnPaint)
    EVT_MOTION (ModelPanel::OnMouseMove)
END_EVENT_TABLE()
